﻿namespace Dcms.UpdateModule
{
    using Dcms.BLL;
    using Dcms.Common;
    using Dcms.Model;
    using System;
    using System.Web;

    public class DcmsJobApply : IHttpHandler
    {
        public void ProcessRequest(HttpContext ctx)
        {
            Dcms_JobSeekerBLL rbll = new Dcms_JobSeekerBLL();
            Dcms_JobSeekerModel model = new Dcms_JobSeekerModel();
            model.Js_AboutEdu = DcmsRequest.GetFormString("AboutEdu");
            model.Js_AboutFamily = DcmsRequest.GetFormString("AboutFamily");
            model.Js_AboutTrain = DcmsRequest.GetFormString("AboutTrain");
            model.Js_AboutWork = DcmsRequest.GetFormString("AboutWork");
            model.Js_Address = DcmsRequest.GetFormString("Address");
            model.Js_AddTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
            model.Js_Birth = Convert.ToDateTime(DcmsRequest.GetFormString("Birth"));
            model.Js_Computer = DcmsRequest.GetFormString("Computer");
            model.Js_Email = DcmsRequest.GetFormString("Email");
            model.Js_FamilyTel = DcmsRequest.GetFormString("FamilyTel");
            model.Js_FirstContacter = DcmsRequest.GetFormString("FirstContacter");
            model.Js_FirstContacterTel = DcmsRequest.GetFormString("FirstContacterTel");
            model.Js_ForeignLanguage = DcmsRequest.GetFormString("ForeignLanguage");
            model.Js_Identity = DcmsRequest.GetFormString("IdentityType") + ":" + DcmsRequest.GetFormString("Identity");
            model.Js_Marry = DcmsRequest.GetInt("Marry", 0);
            model.Js_National = DcmsRequest.GetFormString("National");
            model.Js_PayDemands = DcmsRequest.GetFormString("PayDemands");
            model.Js_RealName = DcmsRequest.GetFormString("RealName");
            model.Js_Sex = DcmsRequest.GetInt("Sex", 0);
            model.Js_Tel = DcmsRequest.GetFormString("Tel");
            model.Js_WorkPlace = DcmsRequest.GetFormString("WorkPlace");
            model.Js_WorkTime = DcmsRequest.GetFormString("WorkTime");
            model.Js_HighEdu = DcmsRequest.GetFormString("HighEdu");
            rbll.AddModel(model);
            Dcms_CandidateRecordBLL dbll = new Dcms_CandidateRecordBLL();
            Dcms_CandidateRecordModel model2 = new Dcms_CandidateRecordModel();
            int num = Utils.StrToInt(rbll.GetDataCount("Select top 1 Js_Id From Dcms_JobSeeker Order By Js_Id Desc"), 0);
            int @int = DcmsRequest.GetInt("pID", 0);
            model2.Cr_AddTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
            model2.Cr_jId = num;
            model2.Cr_pId = @int;
            model2.Cr_State = "0";
            if (model.Js_RealName.Length <= 0 || model.Js_Email.Length <= 0)
                Jscript.AlertAndBack(DcmsRequest.GetFormString("errorMessage"));
            else
            {
                dbll.AddModel(model2);
                Jscript.AlertAndRedirect(DcmsRequest.GetFormString("successMessage"), DcmsRequest.GetFormString("successUrl"));
            }
        }

        public bool IsReusable
        {
            get
            {
                return true;
            }
        }
    }
}

